In distributed data processing systems, data objects or resources, such as database tables, indexes, files, and other data structures, are often shared by multiple processes. If a data object or resource is accessed by two or more processes during the same time interval, problems may arise depending on the nature of the access. For example, if one process attempts to write a data object while another process is reading the data object, an inconsistent set of data may be obtained by the reading process. Similarly, if two processes attempt to write to the same data object during the same time interval, data corruption may result.
In a distributed processing environment, objects are typically accessed in the context of transactions. A transaction is an atomic unit of work. When an object is about to be accessed in the context of a particular transaction, but is already in use by another transaction, then the second transaction will often be required to wait until the first transaction has completed in order to ensure that each transaction accomplishes a logically consistent update. Because transactions are operating on multiple objects asynchronously, it is possible that a transaction that is about to go into a wait state may be doing so to wait for a second transaction that is already waiting on the first transaction for access to another resource. This is commonly called a deadlock as each transaction may wait for another indefinitely.
Even if a transaction is not involved in a deadlock, it might have to wait a considerable amount of time to obtain a lock because of a long-running transaction or transactions holding locks on the objects it needs. In such a situation, one might not want a transaction to wait indefinitely. When a requesting transaction requests the lock held by another transaction, the requesting transaction may set up a timer that will govern how long the requesting transaction will wait for the lock, called a lock wait timeout. In this situation, upon the expiration of the timer, the requesting transaction may just give up the wait for the lock. In such a case, the requesting transaction may never receive the lock and may never finish its task. Considerable time and processing effort may be wasted as a result of deadlocks and lock waits.